package composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: DesignModeProject
 * @description: 大学
 * @author: Li canzhang
 * @create: 2022-05-29 21:38
 **/
public class University extends OrganizationComponent{
    List<OrganizationComponent> organizationComponents = new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }

    //重写add方法
    @Override
    protected void add(OrganizationComponent organizationComponent) {
        this.organizationComponents.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        this.organizationComponents.remove(organizationComponent);
    }

    @Override
    protected void print() {
        System.out.println("---------"+ getName() +"--------");
        for (OrganizationComponent organizationComponent : organizationComponents) {
            organizationComponent.print();
        }
    }
}
